Last updated: 2019-11-18
Checks: 4 2
Knit directory: ~/Research-Local/
This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(12345) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.
| absolute | relative |
|---|---|
| /Users/parajago/Research-Local/RNAseq-Local/Inputs/NigerianTCGA_quants-proteincoding-IHC | RNAseq-Local/Inputs/NigerianTCGA_quants-proteincoding-IHC |
Tracking code development and connecting the code version to the results is critical for reproducibility. To start using Git, open the Terminal and type git init in your project directory.
This project is not being versioned with Git. To obtain the full reproducibility benefits of using workflowr, please see ?wflow_start.
#Translation from HTSeq raw counts -> Count Matrix I have 66 TCGA patients with whole-genome sequencing data and RNAseq data as well as 48 Nigerian patients with RNA-seq data. Raw counts were initially processed using HTSeq, so HTSeq data is being formatted for use with DESeq2 and limma-voom.
FOLDER <- "/Users/parajago/Research-Local/RNAseq-Local/Inputs/NigerianTCGA_quants-proteincoding-IHC"
sampleFiles <- grep("htseq.counts",list.files(FOLDER),value=TRUE)
#Differential gene expression setup based on ethnicity
sampleConditionrace <- sampleFiles
countVar2=1
for (sample in sampleConditionrace){
if (stri_detect_fixed(sample,"LIB")==TRUE){
sampleConditionrace[countVar2] <- "Nigerian"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"black")==TRUE){
sampleConditionrace[countVar2] <- "TCGA_black"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"white")==TRUE){
sampleConditionrace[countVar2] <- "TCGA_white"
countVar2=countVar2+1
} else{
sampleConditionrace[countVar2] <- "TCGA_other"
countVar2=countVar2+1
}
}
#Condition based on IHC subtype
sampleConditionIHC <- sampleFiles
countVar2=1
for (sample in sampleConditionIHC){
if (stri_detect_fixed(sample,"Her2")==TRUE){
sampleConditionIHC[countVar2] <- "Her2"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"TNBC")==TRUE){
sampleConditionIHC[countVar2] <- "TNBC"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"HRpos")==TRUE){
sampleConditionIHC[countVar2] <- "HRpos"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"TPBC")==TRUE){
sampleConditionIHC[countVar2] <- "TPBC"
countVar2=countVar2+1
} else{
sampleConditionIHC[countVar2] <- "Other"
countVar2=countVar2+1
}
}
#Condition based on batch (relevant to the Nigerian patients only; no difference in batch for the TCGA patients)
batchval <- sampleFiles
countVar2=1
for (sample in batchval){
if (stri_detect_fixed(sample,"batch1")==TRUE){
batchval[countVar2] <- "batch1"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch23")==TRUE){
batchval[countVar2] <- "batch23"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch4")==TRUE){
batchval[countVar2] <- "batch4"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"batch5")==TRUE){
batchval[countVar2] <- "batch5"
countVar2=countVar2+1
} else{
batchval[countVar2] <- "batchT"
countVar2=countVar2+1
}
}
#Conditions based on DNA characteristics including chromosome14 LOH, GATA3 mutation status and TP53 mutation status
sampleLOH <-sampleFiles
countVar2=1
for (sample in sampleLOH){
if (stri_detect_fixed(sample,"-noLOH-")==TRUE){
sampleLOH[countVar2] <- "noLOH"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"-LOH-")==TRUE){
sampleLOH[countVar2] <- "LOH"
countVar2=countVar2+1
} else{
sampleLOH[countVar2] <- NA
countVar2=countVar2+1
}
}
sampleGATA3 <-sampleFiles
countVar2=1
for (sample in sampleGATA3){
if (stri_detect_fixed(sample,"GATA3LOH")==TRUE){
sampleGATA3[countVar2] <- "GATA3LOH"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"GATA3mut")==TRUE){
sampleGATA3[countVar2] <- "GATA3mut"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"GATA3wt")==TRUE){
sampleGATA3[countVar2] <- "GATA3wt"
countVar2=countVar2+1
} else{
sampleGATA3[countVar2] <- "NA"
countVar2=countVar2+1
}
}
sampleTP53 <-sampleFiles
countVar2=1
for (sample in sampleTP53){
if (stri_detect_fixed(sample,"TP53wt")==TRUE){
sampleTP53[countVar2] <- "TP53wt"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"TP53single")==TRUE){
sampleTP53[countVar2] <- "TP53single"
countVar2=countVar2+1
} else if (stri_detect_fixed(sample,"TP53double")==TRUE){
sampleTP53[countVar2] <- "TP53double"
countVar2=countVar2+1
} else{
sampleTP53[countVar2] <- "NA"
countVar2=countVar2+1
}
}
table(sampleConditionrace, sampleConditionIHC)
sampleConditionIHC
sampleConditionrace Her2 HRpos TNBC
Nigerian 23 6 19
TCGA_black 0 10 20
TCGA_white 10 10 16
sampleTable <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleConditionIHC,
condition3=sampleLOH,
condition4=sampleGATA3,
condition5=sampleTP53,
batch=batchval)
sampleTable$sampleCondition <- paste(sampleTable$condition1, sampleTable$condition2, sep=".")
ddsHTSeqMF <- DESeqDataSetFromHTSeqCount(sampleTable=sampleTable,
directory=FOLDER,
design=~sampleCondition)
ddsHTSeqMF <- ddsHTSeqMF[rowSums(counts(ddsHTSeqMF)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression -> this removes 731 genes
#Quantile normalization Please refer to: https://parajago.github.io/TCGA-Nigerian-RNAseq/NigerianTCGArawcountsDeSeq2-pc2.html regarding comparison between the Nigerian and TCGA data sets and why quantile normalization under the limma-voom approach was chosen for primary differential expression analysis in any comparisons across populations.
##Data visualization
countmatrix <- assay(ddsHTSeqMF) #Raw counts organized into matrix format from individual files
countmatrix2 <- log2(countmatrix + 1) #Basic transformation of the count data
plot(density(countmatrix2[,1]),lwd=3,ylim=c(0,.30), main="Density of counts with log2[count]+1 transformation ONLY")
for(i in 1:114){lines(density(countmatrix2[,i]),lwd=3)} #This demonstrates that there is a difference in distributions between the Nigerian and TCGA data with basic log transformation normalization
norm_countmatrix <- as.matrix(countmatrix2)
norm_countmatrix = normalize.quantiles(norm_countmatrix)
plot(density(norm_countmatrix[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization")
for(i in 1:114){lines(density(norm_countmatrix[,i]),lwd=3)} #This demonstrates the effect of comparative quantile normalization
colnames (norm_countmatrix) <- colnames (countmatrix2)
rownames (norm_countmatrix) <- rownames (countmatrix2)
norm_countmatrix <- as.data.frame(norm_countmatrix)
countmatrixNigerian <- dplyr::select(norm_countmatrix, contains("LIB"))
plot(density(countmatrixNigerian[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization - Nigerian")
for(i in 1:48){lines(density(countmatrixNigerian[,i]),lwd=3)} #This demonstrates the result of the normalized Nigerian counts separately
tcgacolnames <- colnames(countmatrix)
tcgacolnames <- setdiff(tcgacolnames, colnames(countmatrixNigerian))
countmatrixTCGA <- norm_countmatrix[ , tcgacolnames]
plot(density(countmatrixTCGA[,1]),lwd=3,ylim=c(0,.3), main="Density of counts with quantile normalization - TCGA")
for(i in 1:66){
lines(density(countmatrixTCGA[,i]),lwd=3);
# print(colnames(countmatrix)[i])
# invisible(readline(prompt=i))
} #This demonstrates the result of the normalized TCGA counts separately
norm_countmatrix <- as.data.frame(norm_countmatrix)
t_norm_countmatrix <- t(norm_countmatrix)
t_norm_countmatrix <- cbind (t_norm_countmatrix, sampleTable) #This binds the characteristics of the original patients to the quantile normalized counts. CBinding was checked to make sure that patients were correctly aligned to characteristics.
quant.pca <- prcomp(t_norm_countmatrix[,1:19596])
autoplot(quant.pca, data=t_norm_countmatrix, colour='sampleCondition', main="PCA of quantile normalization results prior to DE analysis")
In the raw data with log transformation only, we are able to see that there are two peaks corresponding to the two datasets (Nigerian and TCGA). The quantile normalization demonstrates a PCA that has similar clustering. Only ~20% of the distribution of the data set is explained by the PCA1, 2 of the variables.
##Differential expression setup
annotation <- as.data.frame(row.names(countmatrix))
colnames(annotation) <- c("GeneID")
annotation$temp <- gsub("[.].+", "", annotation[,1])
annotation$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
annotation$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
annotation$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
annotation$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
annotation$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=annotation$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
annotation$temp <- NULL
design <- t_norm_countmatrix %>% dplyr::select(sampleCondition)
fc = 1.5 #Subsequent threshold of signifcance for log2 fold change -> 0.58 = log2(1.5)
fdr = 0.05 #Subsequent threshold of significance for p-value (adjusted by FDR)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
#DE: HER2 14q LOH (Nigerian)
designNvsTLOH <- t_norm_countmatrix %>% dplyr::select(condition3)
designNvsTLOH$condition3 <- ifelse (designNvsTLOH$condition3=="noLOH", 0, as.character(designNvsTLOH$condition3))
designNvsTLOH$condition3 <- ifelse (designNvsTLOH$condition3=="LOH", 1, as.character(designNvsTLOH$condition3))
designNvsTLOH$condition3 <- ifelse (designNvsTLOH$condition3==0 | designNvsTLOH$condition3==1, designNvsTLOH$condition3, NA)
designNvsTLOH <- designNvsTLOH %>% subset(is.na(condition3)==FALSE)
designNvsTLOH$noLOH <- ifelse (designNvsTLOH$condition3==0, 1, 0)
designNvsTLOH$LOH <- ifelse (designNvsTLOH$condition3==1, 1, 0)
designNvsTLOH$condition3 <- NULL
mm <- model.matrix(~0+designNvsTLOH$noLOH+designNvsTLOH$LOH)
quantids <- rownames(designNvsTLOH)
rownames(mm) <- quantids
colnames(mm) <- c("noLOH", "LOH")
quantdata <- as.data.frame(t(counts(ddsHTSeqMF)))
quantdata <- quantdata[quantids,]
quantdata <- t(quantdata)
d0 <- DGEList(counts=quantdata, genes=annotation)
cutoff <- 10
drop <- which(apply(cpm(d0), 1, max) < cutoff)
d <- d0[-drop,]
dim(d) # Number of genes after taking out low expressed genes
[1] 13844 21
v=voom(d,designNvsTLOH,plot=T, normalize="quantile")
contr.matrix <- makeContrasts(noLOH-LOH, levels=colnames(designNvsTLOH))
fit <- lmFit(v, designNvsTLOH)
fit <- contrasts.fit(fit, contrasts=contr.matrix)
fit <- eBayes(fit)
dt <- decideTests(fit)
summary(dt)
noLOH - LOH
Down 0
NotSig 13844
Up 0
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
No significant differential expression was identified via quantile normalization/voom, which is expected as this method can be overly convservative for inter-group differential expression estimation. We have previously validated DESeq2 for inter-Nigerian comparison.
sampleTableLOH <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
sampleCondition=sampleLOH)
sampleTableLOH <- sampleTableLOH %>% subset(is.na(sampleCondition)==FALSE)
ddsHTSeqMFLOH <- DESeqDataSetFromHTSeqCount(
sampleTable=sampleTableLOH,
directory=FOLDER,
design=~sampleCondition)
ddsHTSeqMFLOH <- ddsHTSeqMFLOH[rowSums(counts(ddsHTSeqMFLOH)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression
ddsLOH <- estimateSizeFactors(ddsHTSeqMFLOH) #The size factor is the median ratio of the sample over a "pseudosample": for each gene, the geometric mean of all samples. This accounts for sequencing depth.
vsd <- vst(ddsHTSeqMFLOH, blind=FALSE) #Variance-stabilizing transformation, only using this since >50 samples
plotPCA(vsd, intgroup=c("sampleCondition"))
ddsLOH <- DESeq(ddsHTSeqMFLOH)
resultsNames(ddsLOH)
[1] "Intercept" "sampleCondition_noLOH_vs_LOH"
cat("MA Plot: Differential expression in Nigerian breast cancer patients based on 14q LOH")
MA Plot: Differential expression in Nigerian breast cancer patients based on 14q LOH
resLOH <- lfcShrink(ddsLOH, coef="sampleCondition_noLOH_vs_LOH", type="ashr", optmethod = "mixEM")
DESeq2::plotMA(resLOH, ylim=c(-10,10), xlim=c(0.1,200))
diffLOH<- results(ddsLOH, contrast=c("sampleCondition", "noLOH", "LOH"), pAdjustMethod ="fdr", alpha=fdr)
diffLOH$foldChange <- NA
row.pos <- which(! is.na(diffLOH$log2FoldChange) &
diffLOH$log2FoldChange >= 0)
row.neg <- which(! is.na(diffLOH$log2FoldChange) &
diffLOH$log2FoldChange < 0)
diffLOH$foldChange[row.pos] <- 2^diffLOH$log2FoldChange[row.pos]
diffLOH$foldChange[row.neg] <- -2^((-1) * diffLOH$log2FoldChange[row.neg])
nrow(diffLOH)
[1] 19071
diffLOH <- diffLOH[(diffLOH$foldChange > fc | diffLOH$foldChange < -fc),]
diffLOH <- subset(diffLOH, padj < fdr)
nrow(diffLOH)
[1] 100
restemp <- lfcShrink(ddsLOH, contrast=c("sampleCondition", "noLOH", "LOH"), res = diffLOH, type="ashr", optmethod = "mixEM")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in Nigerian patients with and without 14q LOH", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffLOHtable <- as.data.frame(diffLOH)
diffLOHtable$temp <- row.names(diffLOH)
diffLOHtable$temp <- gsub("[.].+", "", diffLOHtable$temp)
diffLOHtable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffLOHtable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffLOHtable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffLOHtable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffLOHtable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffLOHtable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffLOHtable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffLOHtable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffLOHtable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffLOHtable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffLOHtable$temp <- NULL
diffLOHtable <- diffLOHtable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffLOHtable, 10, foldChange)
top_n(diffLOHtable, -10, foldChange)
diffLOHtable$baseMean <- NULL
write.csv(diffLOHtable, file = "RNA-DE-Nigerian-14q-LOH.csv", row.names =FALSE)
#Pathway analysis based on 14q LOH in Nigerian samples
diffLOHpath <- results(ddsLOH, contrast=c("sampleCondition", "noLOH", "LOH"), pAdjustMethod ="fdr", alpha=fdr)
diffLOHpath <- as.data.frame(diffLOHpath)
diffLOHpath$foldChange <- NA
row.pos <- which(! is.na(diffLOHpath$log2FoldChange) &
diffLOHpath$log2FoldChange >= 0)
row.neg <- which(! is.na(diffLOHpath$log2FoldChange) &
diffLOHpath$log2FoldChange < 0)
diffLOHpath$foldChange[row.pos] <- 2^diffLOHpath$log2FoldChange[row.pos]
diffLOHpath$foldChange[row.neg] <- -2^((-1) * diffLOHpath$log2FoldChange[row.neg])
diffLOHpath$ENSEMBL <- row.names(diffLOHpath)
diffLOHpath$temp <- row.names(diffLOHpath)
diffLOHpath$temp <- gsub("[.].+", "", diffLOHpath$temp)
diffLOHpath$SYMBOL <- mapIds(EnsDb.Hsapiens.v75,
keys=diffLOHpath$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffLOHpath$baseMean <- NULL
diffLOHpath$log2FoldChange <- NULL
diffLOHpath$temp <- NULL
diffLOHpath.flt <- diffLOHpath[(diffLOHpath$foldChange > fc | diffLOHpath$foldChange < -fc),]
diffLOHpath.flt <- subset(diffLOHpath, padj < fdr)
genes.all <- diffLOHpath
genes.sig <- diffLOHpath.flt
genes.all$ENSEMBL <- gsub('[.]\\d+', '', genes.all$ENSEMBL, perl = TRUE)
genes.sig$ENSEMBL <- gsub('[.]\\d+', '', genes.sig$ENSEMBL, perl = TRUE)
genes.all.anno <- bitr(geneID = genes.all$ENSEMBL,
fromType = 'GENEID',
toType = c('ENTREZID', 'SYMBOL'),
OrgDb = 'EnsDb.Hsapiens.v75',
drop = TRUE)
genes.all.anno <- genes.all.anno[
which(! duplicated(genes.all.anno$ENTREZID)), ]
row.names(genes.all.anno) <- genes.all.anno$ENTREZID
genes.all.anno$ENSEMBL <- genes.all.anno$GENEID
genes.all.anno$GENEID <- NULL
genes.all.anno <- merge(genes.all.anno, genes.all, by = 'ENSEMBL')
row.names(genes.all.anno) <- genes.all.anno$ENTREZID
genes.sig.anno <- genes.all.anno[genes.all.anno$ENSEMBL %in%
genes.sig$ENSEMBL,]
gene.list <- genes.all.anno$foldChange
names(gene.list) <- genes.all.anno$ENTREZID
gene.list <- sort(gene.list, decreasing = TRUE)
ego <- enrichGO(gene = genes.sig.anno$ENTREZID,
universe = as.character(genes.all.anno$ENTREZID),
OrgDb = 'org.Hs.eg.db',
ont = "BP",
pAdjustMethod = "fdr",
pvalueCutoff = 0.05,
readable = TRUE)
as.data.frame(ego)
save(ego, file="GO-LOH.significantgenes.fdr0.05.fc1.5.enrichGO.RData")
write.csv(ego, file="GO-LOH.significantgenes.fdr0.05.fc1.5.enrichGO.csv")
options(jupyter.plot_mimetypes = "image/svg+xml")
options(repr.plot.width = 10, repr.plot.height = 5)
egokegg <- ego
for(i in 1:5) {
egokegg <- dropGO(egokegg, level = i)
}
p1 <- barplot(egokegg)
p2 <- dotplot(egokegg)
kk <- enrichKEGG(gene = genes.sig.anno$ENTREZID,
universe = as.character(genes.all.anno$ENTREZID),
organism = "hsa",
pAdjustMethod = "fdr",
pvalueCutoff = 0.05)
plot(p1)
plot(p2)
save(kk, file="GO-LOH.significantgenes.fdr0.05.fc1.5.enrichKEGG.RData")
write.csv(kk@result, file="GO-LOH.significantgenes.fdr0.05.fc1.5.enrichKEGG.csv")
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
#DE: GATA3 (Nigerian) Among the Nigerian patients, 9 demonstated GATA3 loss of heterozygosity and 9 demonstrated GATA3 mutations, vs. 30 patients who had GATA3 WT. We therefore performed differential expression analysis within this group to see the comparative effects.
sampleTableGATA <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleGATA3,
batch=sampleConditionIHC)
sampleTableGATA$condition1 <- ifelse (grepl("Nigerian",sampleTableGATA$condition1), "Nigerian", NA)
sampleTableGATA <- sampleTableGATA %>% subset(is.na(sampleTableGATA$condition1)==FALSE)
sampleTableGATA$sampleCondition <- sampleTableGATA$condition2
sampleTableGATA$condition1 <- NULL
sampleTableGATA$condition2 <- NULL
ddsHTSeqMFGATA <- DESeqDataSetFromHTSeqCount(
sampleTable=sampleTableGATA,
directory=FOLDER,
design=~sampleCondition+batch)
ddsHTSeqMFGATA <- ddsHTSeqMFGATA[rowSums(counts(ddsHTSeqMFGATA)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression
ddsHTSeqMFGATA$sampleCondition <- relevel(ddsHTSeqMFGATA$sampleCondition, ref = "GATA3wt")
ddsGATA <- estimateSizeFactors(ddsHTSeqMFGATA)
vsdGATA <- vst(ddsHTSeqMFGATA, blind=FALSE)
plotPCA(vsdGATA, intgroup=c("sampleCondition", "batch"))
ddsGATA <- DESeq(ddsHTSeqMFGATA)
resultsNames(ddsGATA)
[1] "Intercept"
[2] "sampleCondition_GATA3LOH_vs_GATA3wt"
[3] "sampleCondition_GATA3mut_vs_GATA3wt"
[4] "batch_HRpos_vs_Her2"
[5] "batch_TNBC_vs_Her2"
cat("MA Plot: Differential expression based on GATA3 LOH status in Nigerians")
MA Plot: Differential expression based on GATA3 LOH status in Nigerians
resGATALOH <- lfcShrink(ddsGATA, coef="sampleCondition_GATA3LOH_vs_GATA3wt", type="ashr")
DESeq2::plotMA(resGATALOH, ylim=c(-10,10), xlim=c(0.1,200))
cat("MA Plot: Differential expression based on GATA3 mutation status in Nigerians")
MA Plot: Differential expression based on GATA3 mutation status in Nigerians
resGATAmut <- lfcShrink(ddsGATA, coef="sampleCondition_GATA3mut_vs_GATA3wt", type="ashr")
DESeq2::plotMA(resGATAmut, ylim=c(-10,10), xlim=c(0.1,200))
plotCounts(ddsGATA, gene="ENSG00000107485.11", intgroup=c("sampleCondition", "batch"), main="Distribution of GATA3 expression by breast cancer subtype / mutation status in Nigerian patients")
diffGATALOH<- results(ddsGATA, contrast=c("sampleCondition", "GATA3LOH", "GATA3wt"), pAdjustMethod ="fdr", alpha=fdr)
diffGATALOH$foldChange <- NA
row.pos <- which(! is.na(diffGATALOH$log2FoldChange) &
diffGATALOH$log2FoldChange >= 0)
row.neg <- which(! is.na(diffGATALOH$log2FoldChange) &
diffGATALOH$log2FoldChange < 0)
diffGATALOH$foldChange[row.pos] <- 2^diffGATALOH$log2FoldChange[row.pos]
diffGATALOH$foldChange[row.neg] <- -2^((-1) * diffGATALOH$log2FoldChange[row.neg])
nrow(diffGATALOH)
[1] 19346
diffGATALOH <- diffGATALOH[(diffGATALOH$foldChange > fc | diffGATALOH$foldChange < -fc),]
diffGATALOH <- subset(diffGATALOH, padj < fdr)
nrow(diffGATALOH)
[1] 262
restemp <- lfcShrink(ddsGATA, contrast=c("sampleCondition", "GATA3LOH", "GATA3wt"), res = diffGATALOH, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in Nigerian patients with and without GATA3 LOH", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffGATALOHtable <- as.data.frame(diffGATALOH)
diffGATALOHtable$temp <- row.names(diffGATALOH)
diffGATALOHtable$temp <- gsub("[.].+", "", diffGATALOHtable$temp)
diffGATALOHtable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATALOHtable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffGATALOHtable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATALOHtable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffGATALOHtable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATALOHtable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffGATALOHtable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATALOHtable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffGATALOHtable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATALOHtable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffGATALOHtable$temp <- NULL
diffGATALOHtable <- diffGATALOHtable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffGATALOHtable, 10, foldChange)
top_n(diffGATALOHtable, -10, foldChange)
diffGATALOHtable$baseMean <- NULL
write.csv(diffGATALOHtable, file = "RNA-DE-Nigerian-GATA3-LOH.csv", row.names =FALSE)
diffGATAmut<- results(ddsGATA, contrast=c("sampleCondition", "GATA3mut", "GATA3wt"), pAdjustMethod ="fdr", alpha=fdr)
diffGATAmut$foldChange <- NA
row.pos <- which(! is.na(diffGATAmut$log2FoldChange) &
diffGATAmut$log2FoldChange >= 0)
row.neg <- which(! is.na(diffGATAmut$log2FoldChange) &
diffGATAmut$log2FoldChange < 0)
diffGATAmut$foldChange[row.pos] <- 2^diffGATAmut$log2FoldChange[row.pos]
diffGATAmut$foldChange[row.neg] <- -2^((-1) * diffGATAmut$log2FoldChange[row.neg])
nrow(diffGATAmut)
[1] 19346
diffGATAmut <- diffGATAmut[(diffGATAmut$foldChange > fc | diffGATAmut$foldChange < -fc),]
diffGATAmut <- subset(diffGATAmut, padj < fdr)
nrow(diffGATAmut)
[1] 1074
restemp <- lfcShrink(ddsGATA, contrast=c("sampleCondition", "GATA3mut", "GATA3wt"), res = diffGATAmut, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in Nigerian patients with and without GATA3 mutations", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffGATAmuttable <- as.data.frame(diffGATAmut)
diffGATAmuttable$temp <- row.names(diffGATAmut)
diffGATAmuttable$temp <- gsub("[.].+", "", diffGATAmuttable$temp)
diffGATAmuttable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATAmuttable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffGATAmuttable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATAmuttable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffGATAmuttable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATAmuttable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffGATAmuttable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATAmuttable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffGATAmuttable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffGATAmuttable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffGATAmuttable$temp <- NULL
diffGATAmuttable <- diffGATAmuttable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffGATAmuttable, 10, foldChange)
top_n(diffGATAmuttable, -10, foldChange)
diffGATAmuttable$baseMean <- NULL
write.csv(diffGATAmuttable, file = "RNA-DE-Nigerian-GATA3-mutations.csv", row.names =FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
All of the TCGA black patients in this sample were GATA3 wild type, so a differential expression analysis could not be performed. Similarly, there were only 4 patients with LOH and 2 with mutations in the TCGA white patients, so any differential expression analysis would be difficult to be performed reliably.
#DE: TP53 (Nigerian) The majority of Nigerian patients had TP53 double hits in their tumors; 10 patients had single hits and 6 patients had WT TP53. We therefore performed differential expression analysis to determine if there were any significant additional expression changes between these groups within the Nigerian patients.
sampleTableTP53 <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleTP53,
batch=sampleConditionIHC)
sampleTableTP53$condition1 <- ifelse (grepl("Nigerian",sampleTableTP53$condition1), "Nigerian", NA)
sampleTableTP53 <- sampleTableTP53 %>% subset(is.na(sampleTableTP53$condition1)==FALSE)
sampleTableTP53$sampleCondition <- sampleTableTP53$condition2
sampleTableTP53$condition1 <- NULL
sampleTableTP53$condition2 <- NULL
ddsHTSeqMFTP53 <- DESeqDataSetFromHTSeqCount(
sampleTable=sampleTableTP53,
directory=FOLDER,
design=~sampleCondition+batch)
ddsHTSeqMFTP53 <- ddsHTSeqMFTP53[rowSums(counts(ddsHTSeqMFTP53)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression
ddsHTSeqMFTP53$sampleCondition <- relevel(ddsHTSeqMFTP53$sampleCondition, ref = "TP53wt")
ddsTP53 <- estimateSizeFactors(ddsHTSeqMFTP53)
vsdTP53 <- vst(ddsHTSeqMFTP53, blind=FALSE)
plotPCA(vsdTP53, intgroup=c("sampleCondition", "batch"))
ddsTP53 <- DESeq(ddsHTSeqMFTP53)
resultsNames(ddsTP53)
[1] "Intercept"
[2] "sampleCondition_TP53double_vs_TP53wt"
[3] "sampleCondition_TP53single_vs_TP53wt"
[4] "batch_HRpos_vs_Her2"
[5] "batch_TNBC_vs_Her2"
cat("MA Plot: Differential expression based on TP53 single-hit status in Nigerians")
MA Plot: Differential expression based on TP53 single-hit status in Nigerians
resTP53singlehit <- lfcShrink(ddsTP53, coef="sampleCondition_TP53single_vs_TP53wt", type="ashr")
DESeq2::plotMA(resTP53singlehit, ylim=c(-10,10), xlim=c(0.1,200))
cat("MA Plot: Differential expression based on TP53 double-hit status in Nigerians")
MA Plot: Differential expression based on TP53 double-hit status in Nigerians
resTP53doublehit <- lfcShrink(ddsTP53, coef="sampleCondition_TP53double_vs_TP53wt", type="ashr")
DESeq2::plotMA(resTP53doublehit, ylim=c(-10,10), xlim=c(0.1,200))
plotCounts(ddsTP53, gene="ENSG00000141510.11", intgroup=c("sampleCondition", "batch"), main="Distribution of TP53 expression by breast cancer subtype / hit status in Nigerian patients")
diffTP53single<- results(ddsTP53, contrast=c("sampleCondition", "TP53single", "TP53wt"), pAdjustMethod ="fdr", alpha=fdr)
diffTP53single$foldChange <- NA
row.pos <- which(! is.na(diffTP53single$log2FoldChange) &
diffTP53single$log2FoldChange >= 0)
row.neg <- which(! is.na(diffTP53single$log2FoldChange) &
diffTP53single$log2FoldChange < 0)
diffTP53single$foldChange[row.pos] <- 2^diffTP53single$log2FoldChange[row.pos]
diffTP53single$foldChange[row.neg] <- -2^((-1) * diffTP53single$log2FoldChange[row.neg])
nrow(diffTP53single)
[1] 19346
diffTP53single <- diffTP53single[(diffTP53single$foldChange > fc | diffTP53single$foldChange < -fc),]
diffTP53single <- subset(diffTP53single, padj < fdr)
nrow(diffTP53single)
[1] 36
restemp <- lfcShrink(ddsTP53, contrast=c("sampleCondition", "TP53single", "TP53wt"), res = diffTP53single, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in Nigerian patients with and without TP53 single-hit mutations", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffTP53singletable <- as.data.frame(diffTP53single)
diffTP53singletable$temp <- row.names(diffTP53single)
diffTP53singletable$temp <- gsub("[.].+", "", diffTP53singletable$temp)
diffTP53singletable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffTP53singletable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffTP53singletable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffTP53singletable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffTP53singletable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffTP53singletable$temp <- NULL
diffTP53singletable <- diffTP53singletable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffTP53singletable, 10, foldChange)
top_n(diffTP53singletable, -10, foldChange)
diffTP53singletable$baseMean <- NULL
write.csv(diffTP53singletable, file = "RNA-DE-Nigerian-TP53-singlehit.csv", row.names =FALSE)
diffTP53double<- results(ddsTP53, contrast=c("sampleCondition", "TP53double", "TP53wt"), pAdjustMethod ="fdr", alpha=fdr)
diffTP53double$foldChange <- NA
row.pos <- which(! is.na(diffTP53double$log2FoldChange) &
diffTP53double$log2FoldChange >= 0)
row.neg <- which(! is.na(diffTP53double$log2FoldChange) &
diffTP53double$log2FoldChange < 0)
diffTP53double$foldChange[row.pos] <- 2^diffTP53double$log2FoldChange[row.pos]
diffTP53double$foldChange[row.neg] <- -2^((-1) * diffTP53double$log2FoldChange[row.neg])
nrow(diffTP53double)
[1] 19346
diffTP53double <- diffTP53double[(diffTP53double$foldChange > fc | diffTP53double$foldChange < -fc),]
diffTP53double <- subset(diffTP53double, padj < fdr)
nrow(diffTP53double)
[1] 356
restemp <- lfcShrink(ddsTP53, contrast=c("sampleCondition", "TP53double", "TP53wt"), res = diffTP53double, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in Nigerian patients with and without TP53 double hit mutations", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffTP53doubletable <- as.data.frame(diffTP53double)
diffTP53doubletable$temp <- row.names(diffTP53double)
diffTP53doubletable$temp <- gsub("[.].+", "", diffTP53doubletable$temp)
diffTP53doubletable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$temp <- NULL
diffTP53doubletable <- diffTP53doubletable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffTP53doubletable, 10, foldChange)
top_n(diffTP53doubletable, -10, foldChange)
diffTP53doubletable$baseMean <- NULL
write.csv(diffTP53doubletable, file = "RNA-DE-Nigerian-TP53-doublehit.csv", row.names =FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
Among the TCGA white patients, 19 were TP53 double-hit, 8 were TP53 single-hit and 9 were TP53 WT. Among the TCGA black patients, 14 were TP53 WT and 16 were TP53 single-hit.
#DE: TP53 (TCGA White)
sampleTableTP53 <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleTP53,
batch=sampleConditionIHC)
sampleTableTP53$condition1 <- ifelse (grepl("TCGA_white",sampleTableTP53$condition1), "TCGA_white", NA)
sampleTableTP53 <- sampleTableTP53 %>% subset(is.na(sampleTableTP53$condition1)==FALSE)
sampleTableTP53$sampleCondition <- sampleTableTP53$condition2
sampleTableTP53$condition1 <- NULL
sampleTableTP53$condition2 <- NULL
ddsHTSeqMFTP53 <- DESeqDataSetFromHTSeqCount(
sampleTable=sampleTableTP53,
directory=FOLDER,
design=~sampleCondition+batch)
ddsHTSeqMFTP53 <- ddsHTSeqMFTP53[rowSums(counts(ddsHTSeqMFTP53)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression
ddsHTSeqMFTP53$sampleCondition <- relevel(ddsHTSeqMFTP53$sampleCondition, ref = "TP53wt")
ddsTP53 <- estimateSizeFactors(ddsHTSeqMFTP53)
vsdTP53 <- vst(ddsHTSeqMFTP53, blind=FALSE)
plotPCA(vsdTP53, intgroup=c("sampleCondition", "batch"))
ddsTP53 <- DESeq(ddsHTSeqMFTP53)
resultsNames(ddsTP53)
[1] "Intercept"
[2] "sampleCondition_TP53double_vs_TP53wt"
[3] "sampleCondition_TP53single_vs_TP53wt"
[4] "batch_HRpos_vs_Her2"
[5] "batch_TNBC_vs_Her2"
cat("MA Plot: Differential expression based on TP53 single-hit status in TCGA white patients")
MA Plot: Differential expression based on TP53 single-hit status in TCGA white patients
resTP53singlehit <- lfcShrink(ddsTP53, coef="sampleCondition_TP53single_vs_TP53wt", type="ashr")
DESeq2::plotMA(resTP53singlehit, ylim=c(-10,10), xlim=c(0.1,200))
cat("MA Plot: Differential expression based on TP53 double-hit status in TCGA white patients")
MA Plot: Differential expression based on TP53 double-hit status in TCGA white patients
resTP53doublehit <- lfcShrink(ddsTP53, coef="sampleCondition_TP53double_vs_TP53wt", type="ashr")
DESeq2::plotMA(resTP53doublehit, ylim=c(-10,10), xlim=c(0.1,200))
plotCounts(ddsTP53, gene="ENSG00000141510.11", intgroup=c("sampleCondition", "batch"), main="Distribution of TP53 expression by breast cancer subtype / hit status in TCGA white patients")
diffTP53single<- results(ddsTP53, contrast=c("sampleCondition", "TP53single", "TP53wt"), pAdjustMethod ="fdr", alpha=fdr)
diffTP53single$foldChange <- NA
row.pos <- which(! is.na(diffTP53single$log2FoldChange) &
diffTP53single$log2FoldChange >= 0)
row.neg <- which(! is.na(diffTP53single$log2FoldChange) &
diffTP53single$log2FoldChange < 0)
diffTP53single$foldChange[row.pos] <- 2^diffTP53single$log2FoldChange[row.pos]
diffTP53single$foldChange[row.neg] <- -2^((-1) * diffTP53single$log2FoldChange[row.neg])
nrow(diffTP53single)
[1] 18886
diffTP53single <- diffTP53single[(diffTP53single$foldChange > fc | diffTP53single$foldChange < -fc),]
diffTP53single <- subset(diffTP53single, padj < fdr)
nrow(diffTP53single)
[1] 39
restemp <- lfcShrink(ddsTP53, contrast=c("sampleCondition", "TP53single", "TP53wt"), res = diffTP53single, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in TCGA white patients with and without TP53 single-hit mutations", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffTP53singletable <- as.data.frame(diffTP53single)
diffTP53singletable$temp <- row.names(diffTP53single)
diffTP53singletable$temp <- gsub("[.].+", "", diffTP53singletable$temp)
diffTP53singletable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffTP53singletable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffTP53singletable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffTP53singletable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffTP53singletable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffTP53singletable$temp <- NULL
diffTP53singletable <- diffTP53singletable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffTP53singletable, 10, foldChange)
top_n(diffTP53singletable, -10, foldChange)
diffTP53singletable$baseMean <- NULL
write.csv(diffTP53singletable, file = "RNA-DE-TCGA_white-TP53-singlehit.csv", row.names =FALSE)
diffTP53double<- results(ddsTP53, contrast=c("sampleCondition", "TP53double", "TP53wt"), pAdjustMethod ="fdr", alpha=fdr)
diffTP53double$foldChange <- NA
row.pos <- which(! is.na(diffTP53double$log2FoldChange) &
diffTP53double$log2FoldChange >= 0)
row.neg <- which(! is.na(diffTP53double$log2FoldChange) &
diffTP53double$log2FoldChange < 0)
diffTP53double$foldChange[row.pos] <- 2^diffTP53double$log2FoldChange[row.pos]
diffTP53double$foldChange[row.neg] <- -2^((-1) * diffTP53double$log2FoldChange[row.neg])
nrow(diffTP53double)
[1] 18886
diffTP53double <- diffTP53double[(diffTP53double$foldChange > fc | diffTP53double$foldChange < -fc),]
diffTP53double <- subset(diffTP53double, padj < fdr)
nrow(diffTP53double)
[1] 23
restemp <- lfcShrink(ddsTP53, contrast=c("sampleCondition", "TP53double", "TP53wt"), res = diffTP53double, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in TCGA white patients with and without TP53 double hit mutations", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffTP53doubletable <- as.data.frame(diffTP53double)
diffTP53doubletable$temp <- row.names(diffTP53double)
diffTP53doubletable$temp <- gsub("[.].+", "", diffTP53doubletable$temp)
diffTP53doubletable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53doubletable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffTP53doubletable$temp <- NULL
diffTP53doubletable <- diffTP53doubletable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffTP53doubletable, 10, foldChange)
top_n(diffTP53doubletable, -10, foldChange)
diffTP53doubletable$baseMean <- NULL
write.csv(diffTP53doubletable, file = "RNA-DE-TCGA_white-TP53-doublehit.csv", row.names =FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
#DE: TP53 (TCGA Black)
sampleTableTP53 <- data.frame(sampleName=gsub(".htseq.counts","",sampleFiles),
fileName=sampleFiles,
condition1=sampleConditionrace,
condition2=sampleTP53,
batch=sampleConditionIHC)
sampleTableTP53$condition1 <- ifelse (grepl("TCGA_black",sampleTableTP53$condition1), "TCGA_black", NA)
sampleTableTP53 <- sampleTableTP53 %>% subset(is.na(sampleTableTP53$condition1)==FALSE)
sampleTableTP53$sampleCondition <- sampleTableTP53$condition2
sampleTableTP53$condition1 <- NULL
sampleTableTP53$condition2 <- NULL
ddsHTSeqMFTP53 <- DESeqDataSetFromHTSeqCount(
sampleTable=sampleTableTP53,
directory=FOLDER,
design=~sampleCondition+batch)
ddsHTSeqMFTP53 <- ddsHTSeqMFTP53[rowSums(counts(ddsHTSeqMFTP53)) > 0, ] #Pre-filtering the dataset by removing the rows without any information about gene expression
ddsHTSeqMFTP53$sampleCondition <- relevel(ddsHTSeqMFTP53$sampleCondition, ref = "TP53wt")
ddsTP53 <- estimateSizeFactors(ddsHTSeqMFTP53)
vsdTP53 <- vst(ddsHTSeqMFTP53, blind=FALSE)
plotPCA(vsdTP53, intgroup=c("sampleCondition", "batch"))
ddsTP53 <- DESeq(ddsHTSeqMFTP53)
resultsNames(ddsTP53)
[1] "Intercept"
[2] "sampleCondition_TP53single_vs_TP53wt"
[3] "batch_TNBC_vs_HRpos"
cat("MA Plot: Differential expression based on TP53 single-hit status in TCGA black patients")
MA Plot: Differential expression based on TP53 single-hit status in TCGA black patients
resTP53singlehit <- lfcShrink(ddsTP53, coef="sampleCondition_TP53single_vs_TP53wt", type="ashr")
DESeq2::plotMA(resTP53singlehit, ylim=c(-10,10), xlim=c(0.1,200))
plotCounts(ddsTP53, gene="ENSG00000141510.11", intgroup=c("sampleCondition", "batch"), main="Distribution of TP53 expression by breast cancer subtype / hit status in TCGA black patients")
diffTP53single<- results(ddsTP53, contrast=c("sampleCondition", "TP53single", "TP53wt"), pAdjustMethod ="fdr", alpha=fdr)
diffTP53single$foldChange <- NA
row.pos <- which(! is.na(diffTP53single$log2FoldChange) &
diffTP53single$log2FoldChange >= 0)
row.neg <- which(! is.na(diffTP53single$log2FoldChange) &
diffTP53single$log2FoldChange < 0)
diffTP53single$foldChange[row.pos] <- 2^diffTP53single$log2FoldChange[row.pos]
diffTP53single$foldChange[row.neg] <- -2^((-1) * diffTP53single$log2FoldChange[row.neg])
nrow(diffTP53single)
[1] 18870
diffTP53single <- diffTP53single[(diffTP53single$foldChange > fc | diffTP53single$foldChange < -fc),]
diffTP53single <- subset(diffTP53single, padj < fdr)
nrow(diffTP53single)
[1] 136
restemp <- lfcShrink(ddsTP53, contrast=c("sampleCondition", "TP53single", "TP53wt"), res = diffTP53single, type="ashr")
restemp$temp <- row.names(restemp)
restemp$temp <- gsub("[.].+", "", restemp$temp)
restemp$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=restemp$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
with(restemp, plot(log2FoldChange, -log10(padj), pch=20, main="Volcano plot of differential gene expression between \nbreast cancers in TCGA black patients with and without TP53 single-hit mutations", xlim=c(-60,60), ylim=c(0,60)))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), points(log2FoldChange, -log10(padj), pch=20, col="blue"))
with(subset(restemp, padj<0.05 & (2^(abs(log2FoldChange))>50)), textxy(log2FoldChange, -log10(padj), labs=symbol, cex=.5))
diffTP53singletable <- as.data.frame(diffTP53single)
diffTP53singletable$temp <- row.names(diffTP53single)
diffTP53singletable$temp <- gsub("[.].+", "", diffTP53singletable$temp)
diffTP53singletable$symbol <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="SYMBOL",
keytype="GENEID",
multiVals="first")
diffTP53singletable$biotype <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENEBIOTYPE",
keytype="GENEID",
multiVals="first")
diffTP53singletable$chr <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="SEQNAME",
keytype="GENEID",
multiVals="first")
diffTP53singletable$locstart <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENESEQSTART",
keytype="GENEID",
multiVals="first")
diffTP53singletable$locend <- mapIds(EnsDb.Hsapiens.v75,
keys=diffTP53singletable$temp,
column="GENESEQEND",
keytype="GENEID",
multiVals="first")
diffTP53singletable$temp <- NULL
diffTP53singletable <- diffTP53singletable %>% arrange(foldChange) %>% dplyr::filter(padj < 0.05) %>% dplyr::filter(abs(foldChange)>1.5)
top_n(diffTP53singletable, 10, foldChange)
top_n(diffTP53singletable, -10, foldChange)
diffTP53singletable$baseMean <- NULL
write.csv(diffTP53singletable, file = "RNA-DE-TCGA_black-TP53-singlehit.csv", row.names =FALSE)
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
#DE: Nigerian/TCGA White - TNBC
#DE: Nigerian/TCGA Black - TNBC
#DE: Nigerian/TCGA White - HR+2-
#DE: Nigerian/TCGA Black - HR+2-
#DE: Nigerian/TCGA White - HER2 (no TCGA Black HER2+ patients)
sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats4 grid stats graphics grDevices utils
[8] datasets methods base
other attached packages:
[1] AnnotationHub_2.16.1 BiocFileCache_1.8.0
[3] dbplyr_1.4.2 Glimma_1.12.0
[5] RColorBrewer_1.1-2 preprocessCore_1.46.0
[7] ashr_2.2-32 ggfortify_0.4.7
[9] calibrate_1.7.2 MASS_7.3-51.4
[11] sva_3.32.1 mgcv_1.8-28
[13] nlme_3.1-140 EnsDb.Hsapiens.v75_2.99.0
[15] ensembldb_2.8.0 AnnotationFilter_1.8.0
[17] GenomicFeatures_1.36.1 hexbin_1.27.3
[19] stringi_1.4.3 dplyr_0.8.1
[21] affy_1.62.0 checkmate_1.9.3
[23] pathview_1.24.0 org.Hs.eg.db_3.8.2
[25] AnnotationDbi_1.46.0 clusterProfiler_3.12.0
[27] pheatmap_1.0.12 genefilter_1.66.0
[29] vsn_3.52.0 RUVSeq_1.18.0
[31] EDASeq_2.18.0 ShortRead_1.42.0
[33] GenomicAlignments_1.20.0 Rsamtools_2.0.0
[35] Biostrings_2.52.0 XVector_0.24.0
[37] DESeq2_1.24.0 SummarizedExperiment_1.14.0
[39] DelayedArray_0.10.0 BiocParallel_1.18.0
[41] matrixStats_0.54.0 Biobase_2.44.0
[43] GenomicRanges_1.36.0 GenomeInfoDb_1.20.0
[45] IRanges_2.18.1 S4Vectors_0.22.0
[47] BiocGenerics_0.30.0 edgeR_3.26.4
[49] limma_3.40.2 ggbiplot_0.55
[51] scales_1.0.0 plyr_1.8.4
[53] ggplot2_3.1.1 gplots_3.0.1.1
loaded via a namespace (and not attached):
[1] R.utils_2.8.0 tidyselect_0.2.5
[3] RSQLite_2.1.1 htmlwidgets_1.3
[5] DESeq_1.36.0 munsell_0.5.0
[7] codetools_0.2-16 withr_2.1.2
[9] colorspace_1.4-1 GOSemSim_2.10.0
[11] highr_0.8 knitr_1.23
[13] rstudioapi_0.10 pscl_1.5.2
[15] DOSE_3.10.1 labeling_0.3
[17] git2r_0.25.2 KEGGgraph_1.44.0
[19] urltools_1.7.3 GenomeInfoDbData_1.2.1
[21] mixsqp_0.1-97 hwriter_1.3.2
[23] polyclip_1.10-0 bit64_0.9-7
[25] farver_1.1.0 rprojroot_1.3-2
[27] xfun_0.7 doParallel_1.0.14
[29] R6_2.4.0 locfit_1.5-9.1
[31] bitops_1.0-6 fgsea_1.10.0
[33] gridGraphics_0.4-1 assertthat_0.2.1
[35] promises_1.0.1 ggraph_1.0.2
[37] nnet_7.3-12 enrichplot_1.4.0
[39] gtable_0.3.0 workflowr_1.4.0
[41] rlang_0.3.4 splines_3.6.0
[43] rtracklayer_1.44.0 lazyeval_0.2.2
[45] acepack_1.4.1 europepmc_0.3
[47] BiocManager_1.30.4 yaml_2.2.0
[49] reshape2_1.4.3 backports_1.1.4
[51] httpuv_1.5.2 qvalue_2.16.0
[53] Hmisc_4.2-0 tools_3.6.0
[55] ggplotify_0.0.3 affyio_1.54.0
[57] ggridges_0.5.1 Rcpp_1.0.1
[59] base64enc_0.1-3 progress_1.2.2
[61] zlibbioc_1.30.0 purrr_0.3.2
[63] RCurl_1.95-4.12 prettyunits_1.0.2
[65] rpart_4.1-15 viridis_0.5.1
[67] cowplot_0.9.4 ggrepel_0.8.1
[69] cluster_2.0.9 fs_1.3.1
[71] magrittr_1.5 data.table_1.12.2
[73] DO.db_2.9 triebeard_0.3.0
[75] truncnorm_1.0-8 SQUAREM_2017.10-1
[77] ProtGenerics_1.16.0 aroma.light_3.14.0
[79] mime_0.7 hms_0.4.2
[81] evaluate_0.14 xtable_1.8-4
[83] XML_3.98-1.20 gridExtra_2.3
[85] compiler_3.6.0 biomaRt_2.40.0
[87] tibble_2.1.3 KernSmooth_2.23-15
[89] crayon_1.3.4 R.oo_1.22.0
[91] htmltools_0.3.6 later_0.8.0
[93] Formula_1.2-3 tidyr_0.8.3
[95] geneplotter_1.62.0 DBI_1.0.0
[97] tweenr_1.0.1 rappdirs_0.3.1
[99] Matrix_1.2-17 R.methodsS3_1.7.1
[101] gdata_2.18.0 igraph_1.2.4.1
[103] pkgconfig_2.0.2 rvcheck_0.1.3
[105] foreign_0.8-71 foreach_1.4.4
[107] xml2_1.2.0 annotate_1.62.0
[109] stringr_1.4.0 digest_0.6.19
[111] graph_1.62.0 rmarkdown_1.13
[113] fastmatch_1.1-0 htmlTable_1.13.1
[115] curl_3.3 shiny_1.3.2
[117] gtools_3.8.1 jsonlite_1.6
[119] viridisLite_0.3.0 pillar_1.4.1
[121] lattice_0.20-38 KEGGREST_1.24.0
[123] httr_1.4.0 survival_2.44-1.1
[125] GO.db_3.8.2 interactiveDisplayBase_1.22.0
[127] glue_1.3.1 UpSetR_1.4.0
[129] iterators_1.0.10 png_0.1-7
[131] bit_1.1-14 Rgraphviz_2.28.0
[133] ggforce_0.2.2 blob_1.1.1
[135] latticeExtra_0.6-28 caTools_1.17.1.2
[137] memoise_1.1.0